﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JSC.Portal.Entities;
using JSC.Portal.Web.Helper;
using JSC.Portal.Module;
using System.Web;
using JSC.Portal.Services;
using JSC.Core;

namespace JSC.Portal.Web.Models
{
    public class DesignPageViewData : TemplatedViewData
    {
        public DesignPageViewData(PortalPage portalPage, string placeholders, string defaultPlaceholder) : base() 
        {
            CurrentPage = portalPage;
            Placeholders = placeholders;
            DefaultPlaceholder = defaultPlaceholder;
        }

        public void Initialize()
        {
            Template = CurrentPage.Template;
            Title = CurrentPage.Name;
            CSS = UrlHelperExtension.EnsureTilde(UrlHelperExtension.Combine(Template.Path, "CSS", Template.CSS));
            foreach (Section s in CurrentPage.Sections)
            {
                ModuleBase module = ModuleBase.GetModuleFromSection(s, true);
                module.Load();
                Modules.Add(module);
            }
        }

        public string DefaultPlaceholder
        {
            get;
            private set;
        }

        public string Placeholders
        {
            get;
            private set;
        }
    }
}
